﻿using GetPwByFreq;
using MathWorks.MATLAB.NET.Arrays;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace JZNJ.RadioMonitorServer.Core
{
    public class USRPDevice
    {
        public event Action<USRPDevice> StateRefreshEvent;
        GetPwByFreq.FunGetPw fus = new FunGetPw();
        MWArray sdrec;

        public IPAddress IP
        {
           get;
           private set;
        }

        public USRPDevice(IPAddress ip,float fs)
        {
            Info = new DeviceInfo();
            this.IP = ip;
            Info.LastTime = DateTime.Now;
            //sdrec = fus.configDevice(1, ip.ToString(), fs)[0];
        }

        public DeviceInfo Info
        {
            get;
            private set;
        }

        public bool Connect(IPAddress ip)
        {
            return true;
        }

        public MWArray RefreshState()
        {
            var time = DateTime.Now;
            List<MWArray[]> values = new List<MWArray[]>();
            for (double start = 1.59E+9; start < 2.6E+9; start += 0.003E+9)
            {
                values.Add(fus.Mat_GetPwByFreq(1, sdrec, start, start + 0.003E+9, 0.003E+9));
            }
            var space = DateTime.Now - time;
            
            return null;
        }

        //public MWArray 
    }

    public class DeviceInfo
    {
        public double Fre { get; set; }

        public double Fs { get; set; }

        public double Tap { get; set; }

        public double Value { get; set; }

        public DateTime LastTime { get; set; }
    }
}
